part of base.widgets;

//泛型扩展：
extension GetWidget<T> on List<T> {
  //banner 轮播图
  Widget banner(
          {Function(int index)? onPageChanged,
          Widget Function(T)? createView}) =>
      isEmpty
          ? Container()
          : GFCarousel(
              pagination: true,
              items: map(
                (item) {
                  if (item is String) {
                    return Container(
                      margin: const EdgeInsets.all(8.0),
                      child: ClipRRect(
                        borderRadius:
                            const BorderRadius.all(Radius.circular(5.0)),
                        child: Image.network(item,
                            fit: BoxFit.cover, width: 1000.0),
                      ),
                    );
                  } else {
                    return createView!(item);
                  }
                },
              ).toList(),
              onPageChanged: onPageChanged);
}
